$m(function(args) {
	window.apiInsight = 'inline';
	/**
	 * 当前分析表的状态
	 */
	var analyseStatus = TempoMineUtils.analyseStatus;
	
	var bindEvent = function(){
		Eventbus.bind("getAnalyseStatus", function(){
			return analyseStatus;
		});
	}
	bindEvent();
	analyseStatus.setType("viewing");
	analyseStatus.setMainId(args.id);

	/**
	 * 获取当前页面流程类型
	 * @returns {*|jQuery}
	 */
	var getFlowType = function () {
		return window.processType;
	}

	//初始化获取当前页面流程类型方法
	Eventbus.one('getFlowType.mine', getFlowType);
	
	
	if(args.isFalbel && args.isFalbel=="true"){
		//15所
		$('#tempo-mine-viewing').layout({
			north : {
				size : '36%',
				spacing_open : 5,
				onresize_end : function() {
				}
			},
			center:{
				onresize_end:function(){
					
				}
			}
		});
	}else{
		$('#tempo-mine-viewing').layout({
			north : {
				resizable : false,
				size : 280,
				spacing_open : 0
			},
			center:{
				onresize_end:function(){
					
				}
			}
		});
	}
	
	
	
	$('#tempo-mine-viewing').show();
	
	var load = function(data) {
		debugger
		if (typeof data == "string") {
			data= JSON.parse(data);
		}
		if (typeof data.alg == "string") {
			data.alg = JSON.parse(data.alg);
			data.i18ndict = JSON.parse(data.i18ndict);
		}
		var alg = data.alg;

		//将获取的所有算法节点保存到页面window对象中
		TempoMineUtils.saveAllAlgorithmNodeInfoToWindow(alg);

		//将国际化字典保存
		var i18ns = data[window.constant.I18NDICT];
		for(var i in i18ns){
			TempoUtils.locale(i,i18ns[i]);
		}
		var groupCategory = function(eles) {
			for(var p in eles){
				var ele = eles[p];
				window[window.constant.MNODES][ele.id] = ele;
				ele.title = ele.name;
				var icon = 'ui-icon tempo-ui-icon tempo-ui-icon-no-mutual tempo-ui-icon-library-unselect';
				ele.icon = icon;
				if(ele.libraryIcon){
					ele.icon += " tempo-mine-library-node-"  + ele.id;
				}
				
			}
		}

		//将获取的所有算法节点图标保存到页面window对象中
		TempoMineUtils.saveAllAlgorithmNodeIconToWindow(groupCategory);

		//当前流程洞察
		if(args.mode!=null && args.mode=="false"){
			MineViewlingController(window.flowid, false);
		}else{
			//发布成果的洞察展示页面
			MineViewlingController(args.id, true, window.exeId);
		}
	}

	/**
	 * 判断当前是否使用缓存数据
	 * @param localStore
	 * @param key
	 * @returns {boolean}
	 */
	var isUseLocalStorage = function (localStore, key) {
		if (localStore && localStore[key]) {
			debugger
			var data = JSON.parse(localStore[key]);
			//处理谷歌87版本显示问题，修改68431bug
			if (typeof data == "string") {
				data = JSON.parse(data);
			}
			if (typeof data.alg == "string") {
				return data.alg.indexOf("metadata") != -1 && data.alg.indexOf("ready") != -1;
			} else {
				var jsonAlg = JSON.stringify(data.alg);
				return jsonAlg.indexOf("metadata") != -1 && jsonAlg.indexOf("ready") != -1;
			}
		}
		return false;
	}

	//从缓存中取节点信息
	var key = "mine_load_data_" + contextLocale;
	var localStore = window.localStorage;
	if (isUseLocalStorage(localStore, key)) {
		var json = JSON.parse(localStore[key]);
		load(json);
	} else {
		$.getQuery({
			url: contextPath + '/api/ai/node/library',
			success: function (sp) {
				var data = sp.data;
				load(data);
				if (localStore) {
					data.md5 = "1";
					localStore[key] = JSON.stringify(data);
				}
			}
		})
	}

});